﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/formdiv.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<link href="#{path.css}ybb/css/prettyPhoto.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/control.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/form.js?v=#{jsVersion}"></script>
<script type="text/javascript" language="JavaScript">
    var filemanage_filecheck_select_allno = "_{filemanage_filecheck_select_allno}";
    var filemanage_filecheck_select_max = "_{filemanage_filecheck_select_max}";
    var filemanage_js_album_select_err = "_{filemanage_js_album_select_err}";
    var fheight = "#{fheight}";
    var loadurl = "#{loadurl}";
    var iframename = "#{iframename}";
    var inputtext = "#{inputtext}";
	
	$(document).ready(function(){
		var h = parseInt(fheight);
		$('#mainbodybottonauto').css({height:h-73});
	})

	function refile(){

		var albumlist=$('input:[name="filelist"]').val();
		if(albumlist){
			filename=albumlist.substring(0,albumlist.length-1);
			parent.frames[iframename].document.getElementById(inputtext).value = filename;
			parent.closeifram();
		}else{
			alert(filemanage_js_album_select_err);
			return false;
		}
	}

	function resetwindow(){
		parent.closeifram();
	}

	function alselected(gid,imgpath,setype){
		var gidstr="#"+gid;

		var maxselect=$('input:[name="maxselect"]').val();

		var albumlist=$('input:[name="filelist"]').val();
		if (setype=='selected'){

			if (maxselect<1){
				alert(filemanage_filecheck_select_max);

				var htmlse='<input type="checkbox" id="'+gid+'" name="selectinfoid" value="'+imgpath+'" onclick="alselected(\''+gid+'\',this.value,\'selected\');">';
				$(htmlse).replaceAll("#"+gid);
				return false;
			}

			var htmlse='<input type="checkbox" id="'+gid+'" name="selectinfoid" value="'+imgpath+'" onclick="alselected(\''+gid+'\',this.value,\'unde\');" checked>';
			$(htmlse).replaceAll("#"+gid);

			var nowid=Number(maxselect)-1;
			$('input:[name="maxselect"]').val(nowid);

			var albumlist=albumlist+imgpath+'|';
			$('input:[name="filelist"]').val(albumlist);
		}else{

			var htmlse='<input type="checkbox" id="'+gid+'" name="selectinfoid" value="'+imgpath+'" onclick="alselected(\''+gid+'\',this.value,\'selected\');">';
			$(htmlse).replaceAll("#"+gid);

			var maxnowid=Number(maxselect)+1;
			$('input:[name="maxselect"]').val(maxnowid);

			var albumlist=albumlist.replace(imgpath+"|","");
			$('input:[name="filelist"]').val(albumlist);
		}
	}
</script>
</head>
	
<body>
<input type="hidden" name="maxselect" value="1"/>
<input type="hidden" name="filelist" value=""/>
<div id="mainwindowhidden">
	<div class="suggestion">
		<span class="sugicon"><span class="strong colorgorning2">_{position_title}</span><span class="padding-left5 colorgorningage">_{mailtemplatemain_listwindow_path_mess}</span></span>
	</div>
	<div class="sugtitle-line"></div>
</div>
<div id="mainbodybottonauto">
	<div class="filelist" id="imglist">
    <%var templateslist = v.data("templateslist") as List<Templates>; %>
	<%if(templateslist.Count>0){ %>
	<%foreach(var row in templateslist){ %>
	<div class="infolist gallery clearfix">
		<table border="0"  style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF">
			<tr>
				<td width="5%">
					<input type="checkbox" id="<%=row.Id %>" name="selectinfoid" value="<%=row.templatecode %>" onclick="alselected('<%=row.Id %>',this.value,'selected');">
				</td>
				<td width="75%" id="left" class="padding-left3"><%=row.templatename %>（<%=row.templatecode %>）</td>
				<td width="20%"><%=row.addtime %></td>
			</tr>
		</table>
	</div>
	<%} %>
	<%}else{ %>
	<div class="infolist">
		<table border="0" style="border-collapse:collapse" width="100%" bordercolor="#FFFFFF">
			<tr>
				<td align="center">_{list_nothing_title}</td>
			</tr>
		</table>
	</div>
	<%} %>
	</div>
</div>

<div id="downbotton" style="margin-top: 5px;">
	<div id="subbotton">
		<table border="0" width="100%">
			<tr id="bottonsubmit">
				<td id="right"><input type="submit" name="Submit" id="submitbotton" onclick="javascript:refile();" value="_{botton_add}" class="buttonface" title="_{botton_add}"/></td>
				<td id="left" class="padding-left5"><input type="reset" name="reset" onclick="javascript:resetwindow();" id="release" value="_{botton_upfile_reset}" class="buttonface"  title="_{botton_upfile_reset}" /></td>
			</tr>
		</table>
	</div>
</div>
</body>

</html>